package tts.model;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

@Entity
@Table(name = "groups", catalog = "test", uniqueConstraints = @UniqueConstraint(columnNames = "groupName"))
public class Groups implements java.io.Serializable {
	
	//fields
	private static final long serialVersionUID = 4033080226116246335L;
	private int groups_id;
	private String groupName;
	private List<Users> usersList = new ArrayList<Users>();
	
	//constructors
	public Groups() {
		super();
	}
	
	public Groups(int id, String groupName, List<Users> usersList) {
		super();
		this.usersList = usersList;
		this.groupName = groupName;
	}

	@Id
	@GeneratedValue
	@Column(name="groups_id", unique = true, nullable = false, length = 10)
	public int getGroups_id() {
		return groups_id;
	}

	public void setGroups_id(int groups_id) {
		this.groups_id = groups_id;
	}
	
	@Column(name = "groupName", unique = true, nullable = false, length = 50)
	public String getGroupName() {
		return groupName;
	}
	public void setGroupName(String groupName) {
		this.groupName = groupName;
	}

	@ManyToMany(mappedBy="groupsList")
	public List<Users> getUsersList() {
		return usersList;
	}
	public void setUsersList(List<Users> usersList) {
		this.usersList = usersList;
	}

	@Override
	public String toString() {
		return "Groups [groups_id=" + groups_id + ", groupName=" + groupName + "]";
	}
}
